package com.ktz.shoping.filter;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

public class EncodingRequestWrapper extends HttpServletRequestWrapper {
	String encoding = "";
	public EncodingRequestWrapper(HttpServletRequest request) {
		super(request);
	}
	public EncodingRequestWrapper(HttpServletRequest request, String encoding) {
		super(request);
		this.encoding = encoding;
	}
	@Override
	public String getParameter(String name) {
		String value = getRequest().getParameter(name);
		try {
			if(value==null||"".equals(value)){
				value = new String(value.trim().getBytes("ISO-8859-1"), encoding);
			}
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return value;
	}

}
